//
// Created by LiuDongPeng on 2024/1/29.
//

#include "Led.h"


Led::Led(stm32_write_pin_t led_set_pin, bool validLevel)
{
    m_led_set_pin_cb = std::move(led_set_pin);
    m_validLevel = validLevel;
}

void Led::on()
{
    m_led_set_pin_cb(m_validLevel);
    m_lastStatus = true;
}

void Led::off()
{
    m_led_set_pin_cb(!m_validLevel);
    m_lastStatus = false;
}

void Led::toggle()
{
    if (m_lastStatus)
    {
        off();
    }
    else
    {
        on();
    }
}
